﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DataAccess
{
    public class SingleTransaction : ITransaction
    {
        private IDataAccess dao;
        private IDbTransaction trans;
        public SingleTransaction(IDataAccess dataAccess)
        {
            dao = dataAccess;
        }

        #region ITransaction 成员

        public void Begin()
        {
            if (dao.IsClosed)
                dao.Open();
            trans = dao.BeginTransaction();
        }

        public void Commit()
        {
            trans.Commit();
        }

        public void Rollback()
        {
            trans.Rollback();
        }

        #endregion
    }
}
